﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLTV_Public;
using System.Data;

namespace QLTV_Data
{
  public  class Lop_Data
    {
      KetNoiCSDL_Data kn = new KetNoiCSDL_Data();

      public DataTable TaoBang(string sql)
      {
          return kn.taobang(sql);
      }
      public DataTable LayDuLieu()
      {
          return kn.LayDuLieu("Load_Lop");
      }
      public int Insert(Lop_Public maLop,Lop_Public tenLop,Lop_Public maDonVi,Lop_Public maHe,Lop_Public maLoaiDG,Lop_Public maThamSo,Lop_Public khoaHoc)
      {
          int Nparameter = 7;
          string[] name = new string[Nparameter];
          object[] value = new object[Nparameter];
          name[0] = "@MaLop";
          value[0] = maLop.MaLop;
          name[1] = "@TenLop";
          value[1] = tenLop.TenLop;
          name[2] = "@MaDonVi";
          value[2] = maDonVi.MaDonVi;
          name[3] = "@MaHe";
          value[3] = maHe.MaHe;
          name[4] = "@MaLoaiDG";
          value[4] = maLoaiDG.MaLoaiDocGia;
          name[5] = "@MaThamSo";
          value[5] = maThamSo.MaThamSo;
          name[6] = "@KhoaHoc";
          value[6] = khoaHoc.KhoaHoc;
          return kn.update("Insert_Lop",name,value,Nparameter);
 
      }
      public int Update(Lop_Public maLop, Lop_Public tenLop, Lop_Public maDonVi, Lop_Public maHe, Lop_Public maLoaiDG, Lop_Public maThamSo, Lop_Public khoaHoc)
      {
          int Nparameter = 7;
          string[] name = new string[Nparameter];
          object[] value = new object[Nparameter];
          name[0] = "@MaLop";
          value[0] = maLop.MaLop;
          name[1] = "@TenLop";
          value[1] = tenLop.TenLop;
          name[2] = "@MaDonVi";
          value[2] = maDonVi.MaDonVi;
          name[3] = "@MaHe";
          value[3] = maHe.MaHe;
          name[4] = "@MaLoaiDG";
          value[4] = maLoaiDG.MaLoaiDocGia;
          name[5] = "@MaThamSo";
          value[5] = maThamSo.MaThamSo;
          name[6] = "@KhoaHoc";
          value[6] = khoaHoc.KhoaHoc;
          return kn.update("Update_Lop", name, value, Nparameter);

      }
      public int Delete(Lop_Public maLop)
      {
          int Nparameter = 1;
          string[] name = new string[Nparameter];
          object[] value = new object[Nparameter];
          name[0] = "@MaLop";
          value[0] = maLop.MaLop;

          return kn.update("Delete_Lop", name, value, Nparameter);

      }
    }
}
